-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add Copy markdown to copy citation #13387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
hey ,can you just guide If I am in the right direction or not. |
You could start by fixing your PR description. |
I have made the changes but not able find the fault as I can't see the effect in ui |
Please add a CHANGELOG.md entry. |
Tried out, UI works... Update The content is a bit strange. I checked the code - it seems, citeproc.java is not used correctly? \[1\]L\. Wegmeth\, T\. Vente\, and J\. Beel\, “Recommender Systems Algorithm Selection for Ranking Prediction on Implicit Feedback Datasets\,” in *Proceedings of the 18th ACM Conference on Recommender Systems*\, in RecSys ’24\. New York\, NY\, USA\: Association for Computing Machinery\, Oct\. 2024\, pp\. 1163–1167\. doi\: 10\.1145\/3640457\.3691718\.<br /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a deeper look, I did not see any wiring in the library https://github.com/michel-kraemer/citeproc-java. Please do so.
@@ -5,7 +5,8 @@ | |||
public enum CitationStyleOutputFormat { | |||
|
|||
HTML("html", OS.NEWLINE + "<br>" + OS.NEWLINE), | |||
TEXT("text", ""); | |||
TEXT("text", ""), | |||
MARKDOWN("markdown", OS.NEWLINE + "<br>" + OS.NEWLINE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<br>
is not a good line separator in markdown. Just remove it. Two empty lines are ok.
@@ -120,6 +121,13 @@ static ClipboardContent processHtml(List<String> citations) { | |||
return content; | |||
} | |||
|
|||
static ClipboardContent processMarkdown(List<String> citations) { | |||
String result = String.join(CitationStyleOutputFormat.MARKDOWN.getLineSeparator(), citations); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the convertion to Markdown made?
I think, you need to deal with setOutputFormat
somehow michel-kraemer/citeproc-java@66cad6b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test so that one "sees" a conversion result in the code.
/** | ||
* Insert each citation into HTML. | ||
* convert HTML to markdown using flexmark. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is trivial and simply restates what the code does without providing additional information about the reasoning or important details about the implementation.
JUnit tests of You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide. |
* convert HTML to markdown using flexmark. | ||
*/ | ||
@VisibleForTesting | ||
static ClipboardContent processMarkdown(List<String> citations) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method uses string concatenation for multiline HTML template instead of Java text blocks ("""). This makes the code less readable and maintainable.
0c2907f
to
b3eb93c
Compare
String actual = markdown.getString(); | ||
|
||
// Print actual output for debugging | ||
System.out.println("=== Actual Markdown Output ==="); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for these, on failure assertEquals will show the diff
// Normalize both strings to ignore whitespace and formatting issues | ||
String normalizedActual = actual.replaceAll("\\s+", " ").trim(); | ||
String normalizedExpected = expected.replaceAll("\\s+", " ").trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are "formatting issues" here specifically?
Given we know the expected string, can we trace where the extra whitespaces might come from in the actual?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually you are right I think I was getting cautious that is why I was removing whitespaces.
but I understood that it overall fails the point of testing.
@trag-bot didn't find any issues in the code! ✅✨ |
* convert HTML to markdown using flexmark. | ||
*/ | ||
@VisibleForTesting | ||
static ClipboardContent processMarkdown(List<String> citations) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You followed @Siedlerchr's recommendation and did not follow mine to use citeproc-java conversion. (michel-kraemer/citeproc-java@66cad6b)
There needs to be AT LEAST a comment, why citeproc-java could not be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unaware of this, good point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe my comment here #13387 (comment) is of help? Just to try out how to route things to that plugin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it works for all previews! Not just csl. I see no advantage in using citeproc here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only point is that find citeproc more configurable than flexmark.
flexmark do that only in one line.
in citeproc I think we have to write a function to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would do case handling
If CSL use citeproc (specialized!, e.g. DOI linked)
If no CSL, use flexmark
Closes #12552
This pr contains the changes by adding the Markdown citation copy in the preview panel.I have added changes StandardAction.java ,RightClickMenu.java,CitationStyleOutputFormat.java,ClipboardContentGenerator.java by adding Markdown format and their style respectively.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)